package com.ydgk.servlet;

import com.alibaba.fastjson.JSON;
import com.ydgk.bean.Supplier;
import com.ydgk.dao.SupplierDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ShowSupplierServlet", urlPatterns = "/ShowSupplierServlet.action")
public class ShowSupplierServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        SupplierDao supplierDao = new SupplierDao();
        List<Supplier> supplierList = supplierDao.findAll();

        String str = JSON.toJSONString(supplierList);

        response.getWriter().print(str);
    }


}
